﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Tetris game by team Coconut</title>
    <script src="shims/deepClone.js"></script>
    <script src="shims/ClassicalOop.js"></script>
    <script src="tetris.js"></script>
    <script src="Vector2D.js"></script>
    <script src="Block.js"></script>
    <script src="_FallingObject.js"></script>
    <script src="FallingL.js"></script>
    <script src="FallingZ.js"></script>
    <script src="FallingLine.js"></script>
    <script src="FallingSquare.js"></script>
    <script src="Earth.js"></script>
</head>
<body>
    <script>
        var earth = new tetris.Earth(4, 8);
        console.log(earth.toString());

        var color = "#FF0000";

        var sq = new tetris.FallingSquare(0, 0, color);
        sq.moveTo(0, 6);
        console.log(sq.toString());
        earth.add(sq);
        console.log(earth.toString());

        sq = new tetris.FallingSquare(0, 0, color);
        sq.moveTo(2, 6);
        earth.add(sq);
        console.log(earth.toString());

        sq = new tetris.FallingSquare(); // Always call the new word when creating new object. Otherwise there are shallow copy issues.
        sq.moveTo(1, 4);
        earth.add(sq);
        console.log(earth.toString());

        var rows = earth.updateBodyAndReturnCollapsedRowsCount(); // It is better to use this method every time after adding a new fallingObject to earth.
        console.log(earth.toString());
        console.log("Collapsed rows count = " + rows);

        var line = new tetris.FallingLine(0, 0, color);
        line.rotate();
        line.moveTo(0, 4);

        earth.add(line);
        console.log(earth.toString());

        line = new tetris.FallingLine(0, 0, color);
        line.rotate();
        line.moveTo(3, 4);

        earth.add(line);
        console.log(earth.toString());

        rows = earth.updateBodyAndReturnCollapsedRowsCount();
        console.log(earth.toString());
        console.log("Collapsed rows count = " + rows);

        sq = new tetris.FallingSquare(0, 0, color);
        sq.moveTo(1, 5);
        earth.add(sq);
        console.log(earth.toString());

        rows = earth.updateBodyAndReturnCollapsedRowsCount();
        console.log(earth.toString());
        console.log("Collapsed rows count = " + rows);
    </script>
</body>
</html>
